<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>common_util: src/common_util/strfmt.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">common_util
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_2961cad218251a7c35c6867350b80887.html">common_util</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">strfmt.h</div></div>
</div><!--header-->
<div class="contents">
<a href="strfmt_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span> </div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;cstdint&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#include &lt;sstream&gt;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="preprocessor">#include &quot;<a class="code" href="timeutil_8h.html">timeutil.h</a>&quot;</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span> </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="keyword">namespace </span>cutl</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span>{</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a2e78cd1710a89e2f94f496bc47cd2d46">   37</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a2e78cd1710a89e2f94f496bc47cd2d46">fmt_uint</a>(uint64_t val, uint8_t width = 0, <span class="keywordtype">char</span> fill = <span class="charliteral">&#39;0&#39;</span>);</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a9b0341d973ea969f0d90e55f4a1771e1">   45</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a9b0341d973ea969f0d90e55f4a1771e1">fmt_double</a>(<span class="keywordtype">double</span> val, <span class="keywordtype">int</span> precision = 2);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span> </div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a9a2a174ed592af8186835cd0da50a384">   55</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a9a2a174ed592af8186835cd0da50a384">fmt_filesize</a>(uint64_t size, <span class="keywordtype">bool</span> simplify = <span class="keyword">true</span>, <span class="keywordtype">int</span> precision = 1);</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"><a class="line" href="strfmt_8h.html#aac4b5055b2dc7e9ccdb2d611d81b8d98">   63</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#aac4b5055b2dc7e9ccdb2d611d81b8d98">fmt_timeduration_s</a>(uint64_t seconds);</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="strfmt_8h.html#ad6111cd3f5b98a59f6c77b00a0d1dc6c">   70</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#ad6111cd3f5b98a59f6c77b00a0d1dc6c">fmt_timeduration_ms</a>(uint64_t microseconds);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a677609cff8def1c22e0a85d823efe811">   77</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a677609cff8def1c22e0a85d823efe811">fmt_timeduration_us</a>(uint64_t nanoseconds);</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span> </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a3fcf54de43bce48a76b654c599b1a9a6">   88</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a3fcf54de43bce48a76b654c599b1a9a6">fmt_timestamp</a>(uint64_t second, <span class="keywordtype">bool</span> local, <span class="keyword">const</span> std::string &amp;fmt);</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a19def540b218ad8b392c77ac0bf0f9e8">   97</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a19def540b218ad8b392c77ac0bf0f9e8">fmt_timestamp_s</a>(uint64_t second, <span class="keywordtype">bool</span> local = <span class="keyword">true</span>);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a003c7af3c7c683a60a11ff0cde64365f">  106</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#a003c7af3c7c683a60a11ff0cde64365f">fmt_timestamp_ms</a>(uint64_t ms, <span class="keywordtype">bool</span> local = <span class="keyword">true</span>);</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"><a class="line" href="strfmt_8h.html#ab5e1423e9aff8e23357419d27380ba13">  115</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#ab5e1423e9aff8e23357419d27380ba13">fmt_timestamp_us</a>(uint64_t us, <span class="keywordtype">bool</span> local = <span class="keyword">true</span>);</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span> </div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"><a class="line" href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">  126</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">to_hex</a>(<span class="keyword">const</span> uint8_t *data, <span class="keywordtype">size_t</span> len, <span class="keywordtype">bool</span> upper = <span class="keyword">true</span>, <span class="keywordtype">char</span> separator = <span class="charliteral">&#39; &#39;</span>);</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a69d9afe63b32912e5dd8191277177efa">  135</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">to_hex</a>(uint8_t value, <span class="keywordtype">bool</span> upper = <span class="keyword">true</span>, <span class="keyword">const</span> std::string &amp;prefix = <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"><a class="line" href="strfmt_8h.html#afee308b97fbeadfab3ee50192f0c1bd3">  144</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">to_hex</a>(uint16_t value, <span class="keywordtype">bool</span> upper = <span class="keyword">true</span>, <span class="keyword">const</span> std::string &amp;prefix = <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a11eceeb09277084a3eb986e2f6a544e7">  153</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">to_hex</a>(uint32_t value, <span class="keywordtype">bool</span> upper = <span class="keyword">true</span>, <span class="keyword">const</span> std::string &amp;prefix = <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a921ce1ac6968f6e45e0faf00109f329f">  162</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">to_hex</a>(uint64_t value, <span class="keywordtype">bool</span> upper = <span class="keyword">true</span>, <span class="keyword">const</span> std::string &amp;prefix = <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span> </div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"><a class="line" href="strfmt_8h.html#ac0fcf92ddbc589cd425dcd268b3ec0fb">  171</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#ac0fcf92ddbc589cd425dcd268b3ec0fb">to_bin</a>(uint8_t value, <span class="keywordtype">char</span> separator = <span class="charliteral">&#39;,&#39;</span>);</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a71f370257e90b2cd1942fbde6b59bf00">  179</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#ac0fcf92ddbc589cd425dcd268b3ec0fb">to_bin</a>(uint16_t value, <span class="keywordtype">char</span> separator = <span class="charliteral">&#39; &#39;</span>);</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"><a class="line" href="strfmt_8h.html#afdda5ff14a10315c15a9101fb30c61e1">  187</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#ac0fcf92ddbc589cd425dcd268b3ec0fb">to_bin</a>(uint32_t value, <span class="keywordtype">char</span> separator = <span class="charliteral">&#39; &#39;</span>);</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"><a class="line" href="strfmt_8h.html#a206058d4c39d850add094c2eb56bfd5d">  195</a></span>    std::string <a class="code hl_function" href="strfmt_8h.html#ac0fcf92ddbc589cd425dcd268b3ec0fb">to_bin</a>(uint64_t value, <span class="keywordtype">char</span> separator = <span class="charliteral">&#39; &#39;</span>);</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span> </div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span>} <span class="comment">// namespace</span></div>
<div class="ttc" id="astrfmt_8h_html_a003c7af3c7c683a60a11ff0cde64365f"><div class="ttname"><a href="strfmt_8h.html#a003c7af3c7c683a60a11ff0cde64365f">cutl::fmt_timestamp_ms</a></div><div class="ttdeci">std::string fmt_timestamp_ms(uint64_t ms, bool local=true)</div><div class="ttdoc">Format a timestamp to a human-readable string.</div></div>
<div class="ttc" id="astrfmt_8h_html_a19def540b218ad8b392c77ac0bf0f9e8"><div class="ttname"><a href="strfmt_8h.html#a19def540b218ad8b392c77ac0bf0f9e8">cutl::fmt_timestamp_s</a></div><div class="ttdeci">std::string fmt_timestamp_s(uint64_t second, bool local=true)</div><div class="ttdoc">Format a timestamp to a human-readable string.</div></div>
<div class="ttc" id="astrfmt_8h_html_a2e78cd1710a89e2f94f496bc47cd2d46"><div class="ttname"><a href="strfmt_8h.html#a2e78cd1710a89e2f94f496bc47cd2d46">cutl::fmt_uint</a></div><div class="ttdeci">std::string fmt_uint(uint64_t val, uint8_t width=0, char fill='0')</div><div class="ttdoc">Format uint64 value to a string with a given width and fill character.</div></div>
<div class="ttc" id="astrfmt_8h_html_a3fcf54de43bce48a76b654c599b1a9a6"><div class="ttname"><a href="strfmt_8h.html#a3fcf54de43bce48a76b654c599b1a9a6">cutl::fmt_timestamp</a></div><div class="ttdeci">std::string fmt_timestamp(uint64_t second, bool local, const std::string &amp;fmt)</div><div class="ttdoc">Format a timestamp to a human-readable string with a given format.</div></div>
<div class="ttc" id="astrfmt_8h_html_a677609cff8def1c22e0a85d823efe811"><div class="ttname"><a href="strfmt_8h.html#a677609cff8def1c22e0a85d823efe811">cutl::fmt_timeduration_us</a></div><div class="ttdeci">std::string fmt_timeduration_us(uint64_t nanoseconds)</div><div class="ttdoc">Format a time duration to a human-readable string.</div></div>
<div class="ttc" id="astrfmt_8h_html_a9a2a174ed592af8186835cd0da50a384"><div class="ttname"><a href="strfmt_8h.html#a9a2a174ed592af8186835cd0da50a384">cutl::fmt_filesize</a></div><div class="ttdeci">std::string fmt_filesize(uint64_t size, bool simplify=true, int precision=1)</div><div class="ttdoc">Format a file size to a human-readable string with a given precision.</div></div>
<div class="ttc" id="astrfmt_8h_html_a9b0341d973ea969f0d90e55f4a1771e1"><div class="ttname"><a href="strfmt_8h.html#a9b0341d973ea969f0d90e55f4a1771e1">cutl::fmt_double</a></div><div class="ttdeci">std::string fmt_double(double val, int precision=2)</div><div class="ttdoc">Format double value to a string with a given precision.</div></div>
<div class="ttc" id="astrfmt_8h_html_aac4b5055b2dc7e9ccdb2d611d81b8d98"><div class="ttname"><a href="strfmt_8h.html#aac4b5055b2dc7e9ccdb2d611d81b8d98">cutl::fmt_timeduration_s</a></div><div class="ttdeci">std::string fmt_timeduration_s(uint64_t seconds)</div><div class="ttdoc">Format a time duration to a human-readable string.</div></div>
<div class="ttc" id="astrfmt_8h_html_ab5e1423e9aff8e23357419d27380ba13"><div class="ttname"><a href="strfmt_8h.html#ab5e1423e9aff8e23357419d27380ba13">cutl::fmt_timestamp_us</a></div><div class="ttdeci">std::string fmt_timestamp_us(uint64_t us, bool local=true)</div><div class="ttdoc">Format a timestamp to a human-readable string.</div></div>
<div class="ttc" id="astrfmt_8h_html_ac0fcf92ddbc589cd425dcd268b3ec0fb"><div class="ttname"><a href="strfmt_8h.html#ac0fcf92ddbc589cd425dcd268b3ec0fb">cutl::to_bin</a></div><div class="ttdeci">std::string to_bin(uint8_t value, char separator=',')</div><div class="ttdoc">Format uint8_t value to a binary string.</div></div>
<div class="ttc" id="astrfmt_8h_html_ad6111cd3f5b98a59f6c77b00a0d1dc6c"><div class="ttname"><a href="strfmt_8h.html#ad6111cd3f5b98a59f6c77b00a0d1dc6c">cutl::fmt_timeduration_ms</a></div><div class="ttdeci">std::string fmt_timeduration_ms(uint64_t microseconds)</div><div class="ttdoc">Format a time duration to a human-readable string.</div></div>
<div class="ttc" id="astrfmt_8h_html_af36c89420f606dcf367cab2d71bb189f"><div class="ttname"><a href="strfmt_8h.html#af36c89420f606dcf367cab2d71bb189f">cutl::to_hex</a></div><div class="ttdeci">std::string to_hex(const uint8_t *data, size_t len, bool upper=true, char separator=' ')</div><div class="ttdoc">Format data to a hex string.</div></div>
<div class="ttc" id="atimeutil_8h_html"><div class="ttname"><a href="timeutil_8h.html">timeutil.h</a></div><div class="ttdoc">Common time utilities.</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>
